<?php

namespace app\common\model;

use think\Model;

class UserRelationships extends Model
{
    protected function getStatusAttr($value)
    {
        $status = [0 => '未激活',1 => '激活'];
        return ['val' => $value, 'text' => $status[$value]];
    }
    protected function getUserInfoAttr($value, $data) {
        $name = model('Users')->field('nickname,mobile,avatar,followers')->where('user_id', $data['user_id'])->find();
        return $name;
    }
    protected function getInviterInfoAttr($value, $data) {
        $name = model('Users')->field('nickname,mobile,avatar,followers')->where('user_id', $data['inviter_id'])->find();
        return $name;
    }
//    protected function getInviterNumAttr($value, $data) {
//        $name = $this->where('inviter_id', $data['inviter_id'])->count();
//        return $name;
//    }
    protected function getGrandpaInfoAttr($value, $data) {
        $name = model('Users')->field('nickname,mobile,avatar,followers')->where('user_id', $data['grandpa_id'])->find();
        return $name;
    }
//    protected function getGrandpaNumAttr($value, $data) {
//        $name = $this->where('inviter_id', $data['grandpa_id'])->count();
//        return $name;
//    }
}
